
export default class Value {

    static readonly ACE = new Value('ACE', 'A', 'Ace', 'A');
    static readonly TWO = new Value('2', '2', 'Two', '2');
    static readonly THREE = new Value('3', '3', 'Three', '3');
    static readonly FOUR = new Value('4', '4', 'Four', '4');
    static readonly FIVE = new Value('5', '5', 'Five', '5');
    static readonly SIX = new Value('6', '6', 'Six', '6');
    static readonly SEVEN = new Value('7', '7', 'Seven', '7');
    static readonly EIGHT = new Value('8', '8', 'Eight', '8');
    static readonly NINE = new Value('9', '9', 'Nine', '9');
    static readonly TEN = new Value('10', '0', 'Ten', '10');
    static readonly JACK = new Value('JACK', 'J', 'Jack', 'J');
    static readonly QUEEN = new Value('QUEEN', 'Q', 'Queen', 'Q');
    static readonly KING = new Value('KING', 'K', 'King', 'K');

    static readonly ALL_VALUES = [
        Value.ACE, Value.TWO, Value.THREE, Value.FOUR, Value.FIVE,
        Value.SIX, Value.SEVEN, Value.EIGHT, Value.NINE, Value.TEN,
        Value.JACK, Value.QUEEN, Value.KING,
    ];

    readonly #name: string;
    readonly #code: string;
    readonly #title: string;
    readonly #shortTitle: string;

    constructor(name: string, code: string, title: string, shortTitle: string) {
        this.#name = name;
        this.#code = code;
        this.#title = title;
        this.#shortTitle = shortTitle;
    }

    get name(): string {
        return this.#name;
    }

    get code(): string {
        return this.#code;
    }

    get title(): string {
        return this.#title;
    }

    get shortTitle(): string {
        return this.#shortTitle;
    }

    static byName(name: string): Value {
        return this.ALL_VALUES.find(value => value.name === name) as Value;
    }
}
